# -*- coding:utf-8 -*-
# --author： jingfeng 
# time: 2019/3/5


import requests
from fake_useragent import UserAgent
import json
from bs4 import BeautifulSoup
import re
import csv

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36',
    'Referer': 'http://www.dianping.com/xian/ch10/g110p3',
    }


def get_teacher_info():
    #  for i in range(1, 81):
    url = 'https://www.dianping.com/xian/ch10/g110'

    response = requests.get(url=url, headers=headers)
    response.encoding = response.apparent_encoding
    if response.status_code ==requests.codes.ok:
        html = response.text
        soup =BeautifulSoup(html,'html5lib')
        get_data(soup)
    else:

        raise (response.status_code,'没有请求成功')

def get_data(selector):
    """
    反爬简析  获取数据
    :param selector:  soup对象
    :return: 
    """

    # 获取css
    css_url = ''
    get_css = requests.get(css_url)
    # 使用正则去匹配


    lis = selector.select()

    for li in lis:
        # 店的名字
        title = li.xpath('./div/a/img/@title')
        # 点评数
        comment_number =
        # 人均消费
        mean_pay=

        # 星数
        stars_number= li.xpath('.//div/span/@title')

        # 地址
        address =

        # 推荐菜
        recommended_food=

        # 优惠
        favourable=

        # 口味评分
        taste_rate =

        # 环境评分
        environmental_rate =

        # 服务评分
        server_rate =


get_teacher_info()
